#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int amount;
	cin >> amount;
	vector<int>val;
	int n;
	val.push_back(0);
	while (cin >> n) {
		val.push_back(n);
		if (cin.get() == '\n') break;
	}
	vector<int>dp(amount + 1, 0);
	dp[0] = 1;
	for (int i = 1; i < val.size(); i++) {
		for (int j = val[i]; j <= amount; j++) {
			dp[j] += dp[j - val[i]];
		}
	}
	cout << dp[amount];
	return 0;
}